﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace HostApplication
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                //creation of a TCP- binary channel on port 12000
                TcpChannel channel = new TcpChannel(12000);
                // channel registration
                ChannelServices.RegisterChannel(channel, true); //secure channel
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(HostObject), "HostObject", WellKnownObjectMode.Singleton); //Singleton design pattern
                Console.WriteLine("Server running!");
                Console.ReadLine();
            }
            catch
            {
                Console.WriteLine("Error creating/registring the channel");
                Console.ReadLine();
            }
        }
    }
}
